<template>
	<view class="content">
		<button type="primary" @click="onoff">{{isLive?'关闭直播':'开启直播'}}</button>
		<button type="primary" @click="admin(1)" class="mg">重置会员状态</button>
		<button type="primary" @click="admin(2)">重置会场状态</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isLive:false
			}
		},
		onShow() {
			uni.showLoading({
				title:'loading',
				mask:true
			})
			uniCloud.callFunction({
				name:'zhibo',
				success: (res) => {
					if (res.result.data[0].zhibo==0) {
						uni.hideLoading()
						this.isLive = false
					} else{
						uni.hideLoading()
						this.isLive = true
					}
				}
			})
		},
		methods: {
			admin(num){
				uniCloud.callFunction({
					name:'seat-admin',
					data:{sign:num}
				}).then((res)=>{
					console.log(res)
				})
			},
			onoff(){
				uni.showLoading({
					title:'loading',
					mask:true
				})
				if (this.isLive) {
					uniCloud.callFunction({
						name:'onofflive',
						data:{status:0},
						success: (res) => {
							console.log(res)
							this.isLive = !this.isLive
							uni.hideLoading()
						}
					})
				} else{
					uniCloud.callFunction({
						name:'onofflive',
						data:{status:1},
						success: (res) => {
							console.log(res)
							this.isLive = !this.isLive
							uni.hideLoading()
						}
					})
				}
				
			}
		}
	}
</script>

<style scoped>
.mg{
	margin: 40rpx 0;
}
</style>
